<template>
  <van-cell-group class="menuList">
    <van-cell
      :title="col.name"
      @click="menuListHandle(col)">
      <van-icon name="arrow" v-if="col.children.length > 0" />
    </van-cell>
    <div :class="show?'':'childNode'" v-if="col.children">
    	// report-menu 根据下面的name的值
      <report-menu v-for="(item, index) in col.children"
      :key="index"
      :col="item"></report-menu>
    </div>
  </van-cell-group>  
</template>
<script>
import { Toast } from 'vant'
import Bus from '../../bus.js'
export default {
  name: 'ReportMenu',
  props: {
    col: {
      type: Object
    }
  },
  data () {
    return {
      show: false
    } 
  },
  methods: {
    menuListHandle (data) {
      if (data.type === 1) {
        if (data.children.length === 0) {
          Bus.$emit('clickmenuhandle', data.id);  
        } else {
          this.show = !this.show
        } 
      } else {
        Toast.fail('此分类不可选')
      }
    }
  }
}
</script>
<style lang="less" scoped>
  .childNode{
      display: none;
    }
</style>